All Questions
7 questions
1vote
1answer
166views
Finding the closest values in a sorted list that don't go under/over
For my project I have a sorted array of objects of timestamps (in milliseconds) and I need two functions. One function should find the closest time that doesn't go over a specific amount, and the ...
-2votes
1answer
189views
Challenge - Construct binary tree from array [closed]
A coding challenge to construct a binary tree from an array. ...
2votes
0answers
51views
Find target in sorted array pivoted at some unknown point in O(log n)
You are given an array sorted in ascending order which is rotated at some pivot unknown to you beforehand. Find your target in \$O(log n)\$ which means it should be a binary search. If the value ...
2votes
2answers
3kviews
Add new number to sorted array of numbers
The task is to add a new number in the array of numbers sorted in ascending order. So let's say the array is: 20,40,50,60 And the number to be inserted is 24, ...
4votes
3answers
160views
My Binary Search Implementation
I have implemented binary search in JavaScript. I run it on node. I pass an comma separated string of numbers in ascending order as first argument and the number to be searched in the second ...
2votes
3answers
469views
Minimum element in a sorted rotated array
A sorted array [0,1,2,3,4,5] when rotated n times (3 times in this case) becomes [3,4,5,0,1,2], meaning elements in the front move to the end. The code below finds the minimum element in this array, ...
5votes
2answers
583views
Binary search that returns bitwise complement of missing index
While re-writing some old JavaScript code to better handle large arrays, I ended up writing my own binary search method. I found many examples of binary search methods written in JavaScript, but all ...